package com.njupt.simulation.utils;

import com.njupt.simulation.entity.LeoSatellite;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

import static com.njupt.simulation.utils.TLEtoLLA.get_sat_only_location_info;

public class TLEtoCoordinate {
    public static double[] tletocoordinate(LeoSatellite leoSatellite,String data){

        String[] sattle_data = {leoSatellite.getLine1(),leoSatellite.getLine2(),leoSatellite.getLine3()};
        // 定义日期格式
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        //将日期字符串转换为 Data对象
        LocalDateTime dateTime = LocalDateTime.parse(data, formatter);
        // 将 LocalDateTime 转换为带有时区的 ZonedDateTime（北京时间，UTC+8）
        ZonedDateTime zonedDateTime = dateTime.atZone(ZoneId.of("Asia/Shanghai"));
        // 将 ZonedDateTime 转换为时间戳（毫秒）
        long timestamp = zonedDateTime.toInstant().toEpochMilli();
        //定义地球站位置
        double[] groundstation_array = new double[]{0, 0, 0};
        double[] coordinate = get_sat_only_location_info(sattle_data,timestamp, groundstation_array);
        return coordinate;
    }

}
